package com.xqq.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import static com.xqq.utils.Constants.KEY;

public class WeatherUtils {
    public static void main(String[] args) {
//        String latitude = "19.7633";
//        String longitude = "96.0785";
//
//        String url = "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/" +
//                latitude +
//                "%2C%20" +
//                longitude +
//                "?unitGroup=metric&include=hours%2Cdays&key=" +
//                KEY +
//                "&contentType=json";
        String s = "{\"id\":508,\"description\":null,\"name\":\"xqq-test07\",\"name_with_namespace\":\"ApplicationTeam / xqq-test07\",\"path\":\"xqq-test07\",\"path_with_namespace\":\"ApplicationTeam/xqq-test07\",\"created_at\":\"2024-12-03T02:35:35.096Z\",\"default_branch\":\"main\",\"tag_list\":[],\"topics\":[],\"ssh_url_to_repo\":\"ssh://git@gitlab.csnd.com:22022/ApplicationTeam/xqq-test07.git\",\"http_url_to_repo\":\"https://gitlab.csnd.com/ApplicationTeam/xqq-test07.git\",\"web_url\":\"http://gitlab.csnd.com/ApplicationTeam/xqq-test07\",\"readme_url\":\"http://gitlab.csnd.com/ApplicationTeam/xqq-test07/-/blob/main/README.md\",\"avatar_url\":null,\"forks_count\":0,\"star_count\":0,\"last_activity_at\":\"2024-12-03T02:35:35.096Z\",\"namespace\":{\"id\":28,\"name\":\"ApplicationTeam\",\"path\":\"ApplicationTeam\",\"kind\":\"group\",\"full_path\":\"ApplicationTeam\",\"parent_id\":null,\"avatar_url\":\"/uploads/-/system/group/avatar/28/A.png\",\"web_url\":\"http://gitlab.csnd.com/groups/ApplicationTeam\"},\"_links\":{\"self\":\"http://gitlab.csnd.com/api/v4/projects/508\",\"issues\":\"http://gitlab.csnd.com/api/v4/projects/508/issues\",\"merge_requests\":\"http://gitlab.csnd.com/api/v4/projects/508/merge_requests\",\"repo_branches\":\"http://gitlab.csnd.com/api/v4/projects/508/repository/branches\",\"labels\":\"http://gitlab.csnd.com/api/v4/projects/508/labels\",\"events\":\"http://gitlab.csnd.com/api/v4/projects/508/events\",\"members\":\"http://gitlab.csnd.com/api/v4/projects/508/members\"},\"packages_enabled\":true,\"empty_repo\":false,\"archived\":false,\"visibility\":\"private\",\"resolve_outdated_diff_discussions\":false,\"container_expiration_policy\":{\"cadence\":\"1d\",\"enabled\":false,\"keep_n\":10,\"older_than\":\"90d\",\"name_regex\":\".*\",\"name_regex_keep\":null,\"next_run_at\":\"2024-12-04T02:35:35.131Z\"},\"issues_enabled\":true,\"merge_requests_enabled\":true,\"wiki_enabled\":true,\"jobs_enabled\":true,\"snippets_enabled\":true,\"container_registry_enabled\":true,\"service_desk_enabled\":false,\"service_desk_address\":null,\"can_create_merge_request_in\":true,\"issues_access_level\":\"enabled\",\"repository_access_level\":\"enabled\",\"merge_requests_access_level\":\"enabled\",\"forking_access_level\":\"enabled\",\"wiki_access_level\":\"enabled\",\"builds_access_level\":\"enabled\",\"snippets_access_level\":\"enabled\",\"pages_access_level\":\"private\",\"operations_access_level\":\"enabled\",\"analytics_access_level\":\"enabled\",\"container_registry_access_level\":\"enabled\",\"emails_disabled\":null,\"shared_runners_enabled\":true,\"lfs_enabled\":true,\"creator_id\":28,\"import_status\":\"none\",\"import_error\":null,\"open_issues_count\":0,\"runners_token\":\"GR1348941BTs8Axx3ESbrGMeH-3xs\",\"ci_default_git_depth\":20,\"ci_forward_deployment_enabled\":true,\"ci_job_token_scope_enabled\":false,\"public_jobs\":true,\"build_git_strategy\":\"fetch\",\"build_timeout\":3600,\"auto_cancel_pending_pipelines\":\"enabled\",\"build_coverage_regex\":null,\"ci_config_path\":null,\"shared_with_groups\":[],\"only_allow_merge_if_pipeline_succeeds\":false,\"allow_merge_on_skipped_pipeline\":null,\"restrict_user_defined_variables\":false,\"request_access_enabled\":true,\"only_allow_merge_if_all_discussions_are_resolved\":false,\"remove_source_branch_after_merge\":true,\"printing_merge_request_link_enabled\":true,\"merge_method\":\"merge\",\"squash_option\":\"default_off\",\"suggestion_commit_message\":null,\"merge_commit_template\":null,\"squash_commit_template\":null,\"auto_devops_enabled\":true,\"auto_devops_deploy_strategy\":\"continuous\",\"autoclose_referenced_issues\":true,\"keep_latest_artifact\":true,\"runner_token_expiration_interval\":null}";
        JsonNode jsonNode = null;
        try {
            jsonNode = new ObjectMapper().readTree(s);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        // 提取 "id" 元素
        String id = jsonNode.get("id").asText();
        System.out.println(id);
    }
}
